package com.lutzyt.delivery.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lutzyt.delivery.bean.Area;
import com.lutzyt.delivery.service.AreaService;
import com.lutzyt.delivery.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * controller 控制器
 *
 * @author zyt
 * @date 2021-05-29
 */
@Slf4j
@RestController
@RequestMapping("/api/area")
public class AreaController {
  private AreaService service;

  @GetMapping
  public Result<List<Area>> list(String id){
    if (id == null || "".equals(id)){
      return Result.success(service.query().eq("parentId", -1).list());
    }
    return Result.success(service.query().eq("parentId", id).list());
  }

  @Autowired
  public void setService(AreaService service) {
    this.service = service;
  }
}
    